<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\BankCards
 *
 * @property-read \App\Models\User $user
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BankCards newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BankCards newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BankCards query()
 * @mixin \Eloquent
 */
class BankCards extends Model
{
    protected $table = 'bank_cards';
    protected $primaryKey = 'id';
    protected $guarded = [];

    public $timestamps = false;

    public static function boot()
    {
        parent::boot(); // TODO: Change the autogenerated stub

        static::creating(function ($model){
            if ($model->created_at) $model->created_at = time();
        });

        static::updating(function ($model){
            if (!$model->updated_at) $model->updated_at = time();
        });
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'uid', 'uid');
    }
}
